package gui;

import java.util.Arrays;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.GridLayout;

public class ComboBox {
  Display display = new Display();
  Shell shell = new Shell(display);

  public ComboBox() {
  shell.setText("Combo box");
  shell.setLayout(new GridLayout(4, false));

  Label label=new Label(shell, SWT.NULL);
  label.setText("What do you like to drink?");
  final Combo combo1 = new Combo(shell, SWT.VERTICAL |
   SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
  final Combo combo2 = new Combo(shell, SWT.VERTICAL| 
   SWT.BORDER  |SWT.READ_ONLY);
  
 combo1.add("Tea");
 combo1.add("Coffee");
 combo1.add("Cold drink");
 combo1.addSelectionListener(new SelectionAdapter() {
 public void widgetSelected(SelectionEvent e) {
  if (combo1.getText().equals("Cold drink")) {
  String[] drinks = new String[]{"Pepsi", "CocaCola", 
   "Miranda","Sprite","ThumbsUp"};
  combo2.setItems(drinks);
  combo2.setEnabled(true);
  combo2.add("-Select-");
  combo2.setText("-Select-");
  } else if (combo1.getText().equals("Tea")) {
  combo2.add("Not Applicable");
  combo2.setText("Not Applicable");
  } else {
  combo2.add("Not Applicable");
  combo2.setText("Not Applicable");
  }
  }
  });
  shell.pack();
  shell.open();
  while (!shell.isDisposed()) {
  if (!display.readAndDispatch()) {
  
  display.sleep();
  }
  }
  display.dispose();
  }
  public static void main(String[] args) {
  new ComboBox();
  }
}